home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 April: Mac OS SDK / Dev.CD Apr 00 SDK1.toast / Development Kits / Hardware / Mac OS USB DDK 1.4.1f4 / Interfaces / UniversalHIDModule.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-02-29  |  4.5 KB  |  149 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        UniversalHIDModule.h
  3.  
  4.     Contains:    This describes the interface a higher level part of the OS uses
  5.                 to talk with a UniversalHIDModule, and the way to implement
  6.                 a UniversalHIDModule compliant HID module.
  7.                 
  8. */
  9. /* We are not USB specific, but we share many definitions with the USB spec*/
  10. #ifndef __UNIVERSALHIDMODULE__
  11. #define __UNIVERSALHIDMODULE__
  12.  
  13. #ifndef __MACTYPES__
  14. #include <MacTypes.h>
  15. #endif
  16. #ifndef __USB__
  17. #include <USB.h>
  18. #endif
  19.  
  20.  
  21.  
  22. #if PRAGMA_ONCE
  23. #pragma once
  24. #endif
  25.  
  26. #ifdef __cplusplus
  27. extern "C" {
  28. #endif
  29.  
  30. #if PRAGMA_IMPORT
  31. #pragma import on
  32. #endif
  33.  
  34. #if PRAGMA_STRUCT_ALIGN
  35.     #pragma options align=mac68k
  36. #elif PRAGMA_STRUCT_PACKPUSH
  37.     #pragma pack(push, 2)
  38. #elif PRAGMA_STRUCT_PACK
  39.     #pragma pack(2)
  40. #endif
  41.  
  42. typedef UInt32                             UHIDModuleConnectionID;
  43. /* FunctionPtr to be called when inturrupt occurs*/
  44. typedef CALLBACK_API_C( void , UHIDInterruptProcPtr )(void *theData, UInt32 refcon);
  45. /* FunctionPtr definitions for UniversalHIDModule dispatch table*/
  46. typedef CALLBACK_API_C( OSStatus , UHIDGetDeviceInfoProcPtr )(UInt32 inInfoSelector, void *outInfo);
  47. typedef CALLBACK_API_C( OSStatus , UHIDGetHIDDescriptorProcPtr )(UInt32 inDescriptorType, UInt32 inDescriptorIndex, UInt32 *ioBufferSize, void *outBuffer);
  48. typedef CALLBACK_API_C( OSStatus , UHIDClaimDeviceProcPtr )(UHIDModuleConnectionID *outConnectionID, UInt32 reserved);
  49. typedef CALLBACK_API_C( OSStatus , UHIDReleaseDeviceProcPtr )(UHIDModuleConnectionID inConnectionID);
  50. typedef CALLBACK_API_C( OSStatus , UHIDInstallInterruptProcPtr )(UHIDModuleConnectionID inConnectionID, UHIDInterruptProcPtr inInterruptProc, UInt32 inRefcon);
  51. typedef CALLBACK_API_C( OSStatus , UHIDControlDeviceProcPtr )(UHIDModuleConnectionID inConnectionID, UInt32 inControlSelector, void *ioControlData);
  52.  
  53. enum {
  54.     kCurrentDispatchTableVersion = 5,
  55.     kOldestCompatableDispatchTableVersion = 5
  56. };
  57.  
  58. /*
  59.    UHIDModuleDispatchTable is exported by the HIDModule's PEF container
  60.    dispatchTableCurrentVersion is kCurrentDispatchTableVersion
  61.    dispatchTableOldestVersion is kOldestCompatableDispatchTableVersion
  62.           (the oldest built client using this API that this UHIDModule will work with)
  63.    vendorID is who wrote this UniversalHIDModule (hi word of 0 and USB vendorID is valid)
  64. */
  65.  
  66. struct UHIDModuleDispatchTableStruct {
  67.     UInt16                             dispatchTableCurrentVersion;
  68.     UInt16                             dispatchTableOldestVersion;
  69.     UInt32                             vendorID;
  70.     UInt32                             vendorSpecific;
  71.     UInt32                             reserved;
  72.     UHIDGetDeviceInfoProcPtr         pUHIDGetDeviceInfo;
  73.     UHIDClaimDeviceProcPtr             pUHIDClaimDevice;
  74.     UHIDReleaseDeviceProcPtr         pUHIDReleaseDevice;
  75.     UHIDInstallInterruptProcPtr     pUHIDInstallInterrupt;
  76.     UHIDControlDeviceProcPtr         pUHIDControlDevice;
  77.     UHIDGetHIDDescriptorProcPtr     pUHIDGetHIDDescriptor;
  78. };
  79. typedef struct UHIDModuleDispatchTableStruct UHIDModuleDispatchTableStruct;
  80.  
  81. typedef UHIDModuleDispatchTableStruct     UHIDModuleDispatchTable;
  82. typedef UHIDModuleDispatchTableStruct *    UHIDModuleDispatchTablePtr;
  83. /* the prototypes for the actual functions in the UHIDModule follow*/
  84. EXTERN_API_C( OSStatus )
  85. UHIDGetDeviceInfo                (UInt32                 inInfoSelector,
  86.                                  void *                    outInfo);
  87.  
  88. EXTERN_API_C( OSStatus )
  89. UHIDGetHIDDescriptor            (UInt32                 inDescriptorType,
  90.                                  UInt32                 inDescriptorIndex,
  91.                                  UInt32 *                ioBufferSize,
  92.                                  void *                    outBuffer);
  93.  
  94. /* Claim and release are a way to insure that only one client is connected*/
  95. EXTERN_API_C( OSStatus )
  96. UHIDClaimDevice                    (UHIDModuleConnectionID * outConnectionID,
  97.                                  UInt32                 reserved);
  98.  
  99. EXTERN_API_C( OSStatus )
  100. UHIDReleaseDevice                (UHIDModuleConnectionID  inConnectionID);
  101.  
  102. EXTERN_API_C( OSStatus )
  103. UHIDInstallInterrupt            (UHIDModuleConnectionID  inConnectionID,
  104.                                  UHIDInterruptProcPtr     inInterruptProc,
  105.                                  UInt32                 inRefcon);
  106.  
  107. EXTERN_API_C( OSStatus )
  108. UHIDControlDevice                (UHIDModuleConnectionID  inConnectionID,
  109.                                  UInt32                 inControlSelector,
  110.                                  void *                    ioControlData);
  111.  
  112. /* these are the constants to be passed to UHIDControlDevice*/
  113.  
  114. enum {
  115.     kUHIDRemoveInterruptHandle    = 0,
  116.     kUHIDVendorSpecificControlStart = 0x00010000
  117. };
  118.  
  119. /* these are the constants to be passed to UHIDGetDeviceInfo*/
  120.  
  121. enum {
  122.     kUHIDGetVendorID            = 0,
  123.     kUHIDGetProductID            = 1,
  124.     kUHIDGetMaxPacketSize        = 2,
  125.     kUHIDVendorSpecificGetInfoStart = 0x00010000
  126. };
  127.  
  128.  
  129. #if PRAGMA_STRUCT_ALIGN
  130.     #pragma options align=reset
  131. #elif PRAGMA_STRUCT_PACKPUSH
  132.     #pragma pack(pop)
  133. #elif PRAGMA_STRUCT_PACK
  134.     #pragma pack()
  135. #endif
  136.  
  137. #ifdef PRAGMA_IMPORT_OFF
  138. #pragma import off
  139. #elif PRAGMA_IMPORT
  140. #pragma import reset
  141. #endif
  142.  
  143. #ifdef __cplusplus
  144. }
  145. #endif
  146.  
  147. #endif /* __UNIVERSALHIDMODULE__ */
  148.  
  149.